//
//  ZYXHuiFuVC.m
//  RuiBeiKang
//
//  Created by iOS开发1 on 2019/1/11.
//  Copyright © 2019年 JW. All rights reserved.
//

#import "ZYXHuiFuVC.h"

#import "ZYXHuiFuDetHeaderCell.h"
#import "ZYXMsgDetCell.h"

#import "ZYXMeaasageModel.h"
#import "ZYXMsgDetHeaderView.h"


#import "KTLOVEComment.h"
#import "ZYXStudyModel.h"
@interface ZYXHuiFuVC ()
@property (strong,nonatomic) NSMutableArray *dataArr;
@property (strong,nonatomic) KTLOVEComment *commentView;

@property (strong,nonatomic) NSString *page;

@property (strong,nonatomic) ZYXStudyInfoModel *headerModel;
@end

@implementation ZYXHuiFuVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"管理员回复";
//    self.tableView.frame = CGRectMake(0,0, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationBar_Height-HEIGHT(45));
        self.tableView.frame = CGRectMake(0,0, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationBar_Height);
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView registerNib:[UINib nibWithNibName:@"ZYXHuiFuDetHeaderCell" bundle:nil] forCellReuseIdentifier:@"ZYXHuiFuDetHeaderCell"];
    [self.tableView registerNib:[UINib nibWithNibName:@"ZYXMsgDetCell" bundle:nil] forCellReuseIdentifier:@"ZYXMsgDetCell"];
    [self.tableView registerNib:[UINib nibWithNibName:@"ZYXMsgDetHeaderView" bundle:nil] forHeaderFooterViewReuseIdentifier:@"ZYXMsgDetHeaderView"];
    
    self.tableView.estimatedRowHeight = HEIGHT(51);
    [self.view addSubview:self.tableView];
    //    NSMutableView *oneView = [[NSMutableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, HEIGHT(48))];
    //    [self.bottomView addSubview:oneView];
    //    self.textField.placeholder = @"  回复 你家派克";
    self.bottomView.hidden = YES;

}
#pragma mark 加载数据
-(void)loadData{
    [NetWork GETWithUrlString:kInterfaceAllUrl(PATH_IndexNewsReply) parmas:@{@"list_id":self.list_id} successBloock:^(NSDictionary *responseObject) {
        NSLog(@"responseObject=%@",responseObject);
        if ([responseObject[@"code"] isEqualToNumber:@200]) {
            
  
                NSArray *modelArr = [ZYXStudyInfoModel mj_objectArrayWithKeyValuesArray:responseObject[@"data"]];
                [self.dataArr addObjectsFromArray:modelArr];
            
            self.headerModel = [ZYXStudyInfoModel mj_objectWithKeyValues:responseObject[@"info"]];
        
            [self.tableView reloadData];
        }else{
            [JKToast showWithText:responseObject[@"message"]];
        }
        
        [self endRefresh];
    } failureBlock:^(NSError *error) {
        [self endRefresh];
    }];
    
}
#pragma mark tableViewDelegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section==0) {
        return 1;
    }else{
        return self.dataArr.count;
    }
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        ZYXHuiFuDetHeaderCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ZYXHuiFuDetHeaderCell"];
        cell.model = self.headerModel;
        return cell;
    }else{
        ZYXStudyInfoModel *model = self.dataArr[indexPath.row];
        ZYXMsgDetCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ZYXMsgDetCell"];
        cell.model = model;
        
        return cell;
    }
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return  UITableViewAutomaticDimension;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    if (section ==1) {
        ZYXMsgDetHeaderView  *view = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"ZYXMsgDetHeaderView"];
        return view;
    }else{
        return  [UIView new];
    }
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        return CGFLOAT_MIN;
    }else{
        return HEIGHT(40);
    }
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"点击查看更多");
//    ZYXMeaasageModel *model = self.dataArr[indexPath.row];
    //    self.textField.placeholder = [NSString stringWithFormat:@"    回复 %@",model.userName];
    
}
- (IBAction)clickCommentn:(UIButton *)sender {
    [self.commentView showView];
    self.commentView.determineClickBlock = ^(NSString *str) {
        
    };
}
#pragma mark 懒加载
-(NSMutableArray *)dataArr{
    if (!_dataArr) {
        _dataArr = [NSMutableArray array];
//        ZYXMeaasageModel *model0 = [[ZYXMeaasageModel alloc]initWitNameStr:@"管理员" content:@"哈哈哈哈哈"];
//        ZYXMeaasageModel *model1 = [[ZYXMeaasageModel alloc]initWitNameStr:@"管理员" content:@"全世界华人团结起来，早日实现中华民族的伟大复兴，我们全世界华人在世人面前才有话语权,在世界的任何地方才不被欺负！"];
//        ZYXMeaasageModel *model2 = [[ZYXMeaasageModel alloc]initWitNameStr:@"我就是我员" content:@"有道理"];
//        ZYXMeaasageModel *model3 = [[ZYXMeaasageModel alloc]initWitNameStr:@"我就是我员" content:@"你真美"];
//        ZYXMeaasageModel *model4 = [[ZYXMeaasageModel alloc]initWitNameStr:@"我就是我" content:@"哈哈哈哈哈哈哈哈哈哈哈哈哈哈"];
//        ZYXMeaasageModel *model5 = [[ZYXMeaasageModel alloc]initWitNameStr:@"我就是我" content:@"哈哈哈哈哈好好好好哈哈哦啊好好哦好好哦啊爱护哦啊好好好哦嗷嗷好哦好"];
//        ZYXMeaasageModel *model6 = [[ZYXMeaasageModel alloc]initWitNameStr:@"管理我就是我" content:@"哈哈哈哈哈"];
//        _dataArr = [NSMutableArray arrayWithObjects:model0,model1,model2,model3,model4,model5,model6, nil];
        
    }
    return _dataArr;
}

#pragma mark 懒加载
- (KTLOVEComment *)commentView{
    if (!_commentView) {
        _commentView = [[KTLOVEComment alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    }
    return _commentView;
}

@end
